package com.web;

import com.domain.Activity;
import com.service.activityService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
 * 员工看所有的活动
 * 不需要接收数据，直接进行查询
 * 提交到 activityService 的 findAllActList 函数
 * 转发到 /activityShow.jsp 页面进行展示
 */
@WebServlet("/findAllAct")//员工看所有的活动
public class findAllActServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.解决乱码
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        //2.调用service层获取所有的活动
        List<Activity> allActList = new activityService().findAllActList();
        System.out.println("获取了所有的活动");
        //3.将所有的活动存入
        request.setAttribute("allAct",allActList);
        //4.转发到页面activityShow.jsp进行展示
        request.getRequestDispatcher("/activityShow.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
